if (SaveAsWhat <> asOutline) and not ((StackInfo^.StackType = RGBStack) and (StackInfo^.nSlices = 3)) then
KillRoi;
SaveAllState := NoSaveAll;
if not ((SaveAsWhat = asTIFF) or (SaveAsWhat = asQuickTime) or (SaveAsWhat = asPICS) or (SaveAsWhat = asPalette) or (SaveAsWhat = asOutline)) then begin
PutError('Stacks can only be saved in TIFF, QuickTime or PICS format.');
SaveAsWhat := asTIFF;
exit(SaveAs);
end;
end;
isSelection := RoiShowing and (RoiType = RectRoi);
if SaveAllState = SaveAllStage1 then begin
SaveRefNum := RefNum;
SaveAllState := SaveAllStage2;
end;
case SaveAsWhat of
asTiff, asRawData:
if isSelection then
SaveSelection(name, RefNum, false)
else
SaveAsTIFF(name, RefNum, 0, 0, false);
asPict:
if isSelection then
SaveAsPICT(name, RefNum, true)
else
SaveAsPICT(name, RefNum, false);
asQuickTime:
SaveAsQuickTime(name, RefNum);
asPICS:
SaveAsPICS(name, RefNum);
AsPalette:
SaveColorTable(name, RefNum);
AsOutline:
SaveOutline(name, RefNum);
end; {case}
if (SaveAsWhat = asRawData) and (SaveAllState <> SaveAllStage2) then
SaveAsWhat := asTIFF;
end; {with}
end;
procedure SaveFile;
var
fname: str255;
size: LongInt;
ok: boolean;
begin
if CurrentWindow = ResultsKind then begin
Export('', 0);
exit(SaveFile);
end;
if CurrentWindow = TextKind then begin
SaveText;
exit(SaveFile);
end;
if OpPending then
KillRoi;
with Info^ do begin
fname := title;
size := 0;
if PictureType = TiffFile then
ok := SaveTiffFile(fname, vref, 0, 0, false)
else if PictureType = PictFile then
ok := SavePICTFile(fname, vref, false, false)
else
SaveAs('', 0);
end;
end;
function SaveChanges: integer;
const
yesID = 1;
noID = 2;
cancelID = 3;
var
id: integer;
reply: SFReply;
begin
id := 0;
if info^.changes then
with info^ do begin
if CommandPeriod or MakingStack or (macro and ((MacroCommand = DisposeC) or (MacroCommand = DisposeAllC))) then begin
SaveChanges := ok;
exit(SaveChanges);
end;
ParamText(title, '', '', '');
InitCursor;
id := alert(600, nil);
if id = yesID then begin
KillRoi;
SaveFile;
InitCursor;
end; {if yes}
end; {if changes}
if (id = cancelID) or ((id = yesID) and (info^.changes)) then
SaveChanges := cancel
else
SaveChanges := ok;
end;
function CloseAWindow (WhichWindow: WindowPtr): integer;
if (kind = PicKind) or (kind = ProfilePlotKind) or (kind = CalibrationPlotKind) or (kind = HistoKind) or (Kind = PasteControlKind) or (Kind = ResultsKind) or (Kind = TextKind) then
SetMenuItem(FileMenuH, CloseItem, ShowItems or (CurrentKind = TextKind) or (CurrentKind = ResultsKind) or (CurrentKind = ProfilePlotKind) or (CurrentKind = CalibrationPlotKind) or (CurrentKind = HistoKind));
end;
case CurrentKind of
ProfilePlotKind, CalibrationPlotKind:
ExportAsWhat := asPlotValues;
HistoKind:
ExportAsWhat := asHistogramValues;
ResultsKind:
ExportAsWhat := asMeasurements;
PicKind: begin
if (SaveAsWhat <> asPICT) then
SaveAsWhat := asTiff;
if (ExportAsWhat > asText) then
ExportAsWhat := asRaw;
end;
otherwise
end;
if isSelection and notStack and (SaveAsWhat <> AsPalette) and (CurrentKind <> ResultsKind) and (CurrentKind <> TextKind) then